package org.gcb.core.model;

import java.awt.datatransfer.DataFlavor;
import javax.swing.Icon;
import javax.swing.event.SwingPropertyChangeSupport;

/**
 *
 * @author Jason
 */
public class Armor extends Item implements IEquippable<EArmorSlot> {
    public static final DataFlavor ArmorFlavor = new DataFlavor(Armor.class, "armor");
    public static final Armor emptySlot = new Armor(null, "Empty Head Slot", "Place holder for an empty head slot.", 4.0, EArmorSlot.HEAD);
    public static final String PROP_ARMOR_BONUS = "armorBonus";
    public static final String PROP_CHECK_PENALTY = "checkPenalty";
    public static final String PROP_SPEED_PENALTY = "speedPenalty";
    /** */
    private final EArmorSlot slot;
    private SwingPropertyChangeSupport propSupport = new SwingPropertyChangeSupport(this, true);
    /** */
    private Integer armorBonus = 0;
    /** */
    private Integer checkPenalty = 0;
    /** */
    private Integer speedPenalty = 0;

    public Armor(Icon icon, String text, String description, Double weight, EArmorSlot slot) {
        super(icon, text, description, weight);
        this.slot = slot;
    }

    public Armor(Icon icon, String text, String description, Double weight, EArmorSlot slot, Integer armorBonus, Integer checkPenalty) {
        super(icon, text, description, weight);
        this.slot = slot;
        this.armorBonus = armorBonus;
        this.checkPenalty = checkPenalty;
    }

    public Armor(Icon icon, String text, String description, Double weight, EArmorSlot slot, Integer armorBonus, Integer checkPenalty, Integer speedPenalty) {
        super(icon, text, description, weight);
        this.slot = slot;
        this.armorBonus = armorBonus;
        this.checkPenalty = checkPenalty;
        this.speedPenalty = speedPenalty;
    }

    /**
     *
     * @return
     */
    @Override
    public EArmorSlot getSlot() {
        return slot;
    }

    public Integer getArmorBonus() {
        return armorBonus;
    }

    public void setArmorBonus(Integer armorBonus) {
        Integer oldArmorBonus = this.armorBonus;
        this.armorBonus = armorBonus;
        propSupport.firePropertyChange(PROP_ARMOR_BONUS, oldArmorBonus, this.armorBonus);
    }

    public Integer getCheckPenalty() {
        return checkPenalty;
    }

    public void setCheckPenalty(Integer checkPenalty) {
        Integer oldCheckPenalty = this.checkPenalty;
        this.checkPenalty = checkPenalty;
        propSupport.firePropertyChange(PROP_CHECK_PENALTY, oldCheckPenalty, this.checkPenalty);
    }

    public Integer getSpeedPenalty() {
        return speedPenalty;
    }

    public void setSpeedPenalty(Integer speedPenalty) {
        Integer oldSpeedPenalty = this.speedPenalty;
        this.speedPenalty = speedPenalty;
        propSupport.firePropertyChange(PROP_SPEED_PENALTY, oldSpeedPenalty, this.speedPenalty);
    }
}
